package cn.tedu.controller;

import cn.tedu.charging.common.pojo.JsonResult;
import cn.tedu.charging.common.pojo.param.GunStatusUpdateParam;
import cn.tedu.charging.common.pojo.vo.StationInfoVO;
import cn.tedu.service.DeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("device")
@Api(tags = "用户模块")
public class DeviceController {
    @Autowired
    private DeviceService deviceService;
    @ApiOperation("获取场站信息")
    @GetMapping("/station/info/{gunId}")
    public JsonResult<StationInfoVO> getStationInfo(@PathVariable("gunId") Integer gunId){
        log.debug("获取场站信息:{}",gunId);
        log.debug("获取场站信息:userService-入参:{}",gunId);
        StationInfoVO stationInfo   = deviceService.getStationInfo(gunId);
        log.debug("获取场站信息:userService-入参:{},出参:{}",gunId,stationInfo);

        JsonResult<StationInfoVO> result = JsonResult.ok(stationInfo,"获取场站信息成功");
        log.debug("获取场站信息：userService-入参:{},出参:{}",gunId,result);
        return result;
    }


    @ApiOperation("更新枪状态")
    @PostMapping ("/station/gun/status/update/")
    public JsonResult<Boolean> updateGunStatus(@RequestBody GunStatusUpdateParam param){
        log.debug("更新枪状态-入参:{}",param);
        log.debug("更新枪状态:deviceService-入参:{}",param);
        Boolean success = deviceService.updateGunStatus(param);
        log.debug("更新枪状态:deviceService-入参:{},出参:{}",param,success);

        JsonResult<Boolean> result = JsonResult.ok(success,"更新枪状态成功");
        log.debug("更新枪状态：deviceService-入参:{},出参:{}",param,result);
        return result;
    }
}